package com.ee.drawableres;

import android.app.Activity;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.LevelListDrawable;
import android.graphics.drawable.ScaleDrawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;

public class MainActivity extends Activity implements OnClickListener {
	ImageButton transitionDrawableBtn;
	ImageView clip;
	ClipDrawable clipdrawable;
	
	ImageView levellist;
	LevelListDrawable levelListdrawable;
	
	ImageView scale;
    ScaleDrawable scaleDrawable ;
    
	int level;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		transitionDrawableBtn = (ImageButton) findViewById(R.id.transition);
		transitionDrawableBtn.setOnClickListener(this);
		
		clip = (ImageView) findViewById(R.id.clip);
		clip.setOnClickListener(this);
		
		clipdrawable = (ClipDrawable) clip.getDrawable();
		clipdrawable.setLevel(5000);
		
		
		levellist = (ImageView)findViewById(R.id.level_list);
		levellist.setOnClickListener(this);
		levelListdrawable = (LevelListDrawable)levellist.getDrawable();
		
		
		scale = (ImageView)findViewById(R.id.scale);  
        scaleDrawable = (ScaleDrawable)scale.getDrawable();  
        scaleDrawable.setLevel(1);
	}
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.clip:
			clipdrawable.setLevel(clipdrawable.getLevel() + 1000);
			break;
		case R.id.transition:
			TransitionDrawable trandrawable = (TransitionDrawable) transitionDrawableBtn.getDrawable();
			trandrawable.startTransition(1500);
			break;
		case R.id.level_list:
			level = levelListdrawable.getLevel();
			levelListdrawable.setLevel(++level);
			level %= 4;
			break;
		default:
			break;
		}
	}
}
